package com.tuangou.tuangouheader.header.controller;

import java.util.Arrays;
import java.util.Map;

import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.tuangou.tuangouheader.header.entity.LevelEntity;
import com.tuangou.tuangouheader.header.service.LevelService;



/**
 * 
 *
 * @author zjb
 * @email zjb@tuangou.com
 * @date 2021-06-17 16:35:50
 */
@RestController
@RequestMapping("header/level")
public class LevelController {
    @Autowired
    private LevelService levelService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("header:level:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = levelService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("header:level:info")
    public R info(@PathVariable("id") Integer id){
		LevelEntity level = levelService.getById(id);

        return R.ok().put("level", level);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("header:level:save")
    public R save(@RequestBody LevelEntity level){
		levelService.save(level);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("header:level:update")
    public R update(@RequestBody LevelEntity level){
		levelService.updateById(level);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("header:level:delete")
    public R delete(@RequestBody Integer[] ids){
		levelService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
